package com.coolw.dynamic.thread.pool.domain.request;

import com.coolw.common.api.BaseDomain;
import com.coolw.dynamic.thread.pool.enums.KeepAliveTimeUnitEnum;
import com.coolw.dynamic.thread.pool.enums.QueueTypeEnum;
import com.coolw.dynamic.thread.pool.enums.RejectedExecutionHandlerEnum;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 线程池新增请求
 *
 * @author coolw
 * @date 2024/5/15 16:30
 */
@Getter
@Setter
public class ThreadPoolConfigAddRequest extends BaseDomain {
    private static final long serialVersionUID = -7960336292072696115L;

    /**
     * 线程池代码
     */
    @NotBlank
    private String poolCode;

    /**
     * 线程池名称
     */
    @NotBlank
    private String poolName;

    /**
     * 核心线程数
     */
    @NotNull
    @Min(1)
    private Integer corePoolSize;

    /**
     * 最大线程数
     */
    @NotNull
    @Min(1)
    private Integer maxPoolSize;

    /**
     * 线程存活时间;默认为60
     */
    private Long keepAliveTime = 60L;

    /**
     * 线程存活时间单位;默认为秒 {@link KeepAliveTimeUnitEnum}
     */
    private String keepAliveTimeUnit = KeepAliveTimeUnitEnum.SECOND.getCode();

    /**
     * 队列类型 {@link QueueTypeEnum}
     */
    @NotBlank
    private String queueType;

    /**
     * 队列大小
     */
    @NotNull
    @Min(1)
    private Integer queueSize;

    /**
     * 拒绝策略;默认为ABORT_POLICY {@link RejectedExecutionHandlerEnum}
     */
    private String rejectStrategy = RejectedExecutionHandlerEnum.ABORT_POLICY.getCode();
}
